package com.shangma.cn.entity.base.impl;

import com.baomidou.mybatisplus.annotation.TableName;
import com.shangma.cn.commons.valid.AddGroup;
import com.shangma.cn.commons.valid.UpdateGroup;
import com.shangma.cn.commons.valid.anno.GenderEnum;
import com.shangma.cn.entity.base.BaseEntity;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import org.springframework.context.annotation.Bean;

import javax.validation.constraints.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 开发人员: 辉哥真球帅
 * 联系方式: zhengzhoudaxuevip@163.com
 * 创建时间: 2021/10/11  9:45
 * 文件含义:
 */
@Data
@TableName("sys_admin")
public class Admin extends BaseEntity {

    @NotBlank(message = "账户名称不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "[a-zA-Z0-9_-]{4,16}", groups = {AddGroup.class, UpdateGroup.class})
    private String accountName;

    @NotBlank(message = "员工名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String adminName;

    @NotBlank(message = "邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Email(message = "请输入正确的邮箱格式", groups = {AddGroup.class, UpdateGroup.class})
    private String adminEmail;
    @NotBlank(message = "手机号不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}", message = "请输入正确的手机格式", groups = {AddGroup.class, UpdateGroup.class})
    private String adminPhone;
    private Double adminSalary;
    @URL(message = "请输入正确的头像连接", groups = {AddGroup.class, UpdateGroup.class})
    private String adminAvatar;
    private String accountPwd;
    @NotBlank(message = "请输入地址", groups = {AddGroup.class, UpdateGroup.class})
    private String adminAddress;

    @NotBlank(message = "请输入身份证号", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]", message = "身份证格式不正确", groups = {AddGroup.class, UpdateGroup.class})
    private String cardCode;

    private Boolean isActive;
    private Boolean isEnable;

    private LocalDateTime updatePasswordLastTime;

    @GenderEnum(values = {0, 1, 2}, message = "请输入正确的性别", groups = {AddGroup.class, UpdateGroup.class})
    private int adminGender;


    private boolean isAdmin;
    private transient List<Long> roleIds = new ArrayList<>();
}
